package com.ruoyi.hk.hanler.enums;

import com.ruoyi.hk.hanler.exception.ResultCode;

import static javax.servlet.http.HttpServletResponse.*;

/**
 * 枚举封装业务级别的状态码
 */
public enum BusinessCode implements ResultCode {

    LOGIN_SUCCESS(SC_OK, "登录成功，欢迎你："),
    TOKEN_NOT_EXISTS(SC_UNAUTHORIZED, "Token不存在"),  //401
    INVALID_TOKEN(SC_UNAUTHORIZED, "无效的Token"),
    USER_NOT_LOGGED(SC_FORBIDDEN, "用户未登录"),   //403
    //自定义的状态码
    REGISTERED_SUCCESSFULLY(499, "注册成功"),
    REGISTERED_ERROR(498, "注册失败"),
    PHONENUMBER_ERROR(497, "手机号重复"),
    NICKNAME_ERROR(496, "昵称重复"),
    USERNAME_ERROR(498, "账号重复");

    private int code;
    private String msg;

    BusinessCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 获取状态码
     */
    @Override
    public Integer getCode() {
        return this.code;
    }

    /**
     * 获取状态信息
     */
    @Override
    public String getMsg() {
        return this.msg;
    }
}